package Thread;
//创建一个线程：在主线程（main）中控制器该线程的结束；
public class Demo10 {
    private  static boolean isFinished=false;
    public static void main(String[] args) throws InterruptedException {

        Thread t = new Thread(() -> {
            while (!isFinished) {
                System.out.println("hello thread");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            System.out.println("thread进程结束");
        });
        t.start();
        Thread.sleep(3000);
        isFinished=true;
    }
}
